package com.chijun.mform.create.mode;


import com.chijun.mform.create.field.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class FormConfig {

    public FormConfig(){

    }
    
    
//    private Field[] fields;                                                 //可使用的字段列表
//    private List<FormGroup> formGroupList;                                  //表单分组列表
//    private List<FormIcon> formIconList;                                    //表单图标列表
//    private List<String> timeType;                                          //时间格式列表

    
    private Form form;                                                      //表单信息
    private List<FormField> formFieldList;                                  //表单选择的字段列表
    private Map<Long,List<FormFieldOption>> formFieldOptionMap;             //字段的选项  Map<字段编号,List<选项mode>>
    private Map<Long,List<FormField>> fieldOptionReMap;                     //选项关联的字段  Map<选项编号,List<表单字段mode>>
    List<FormOptionReField> formOptionReFieldList;                          //选项关联的字段列表
    List<FormApproveProcess> formApproveProcessList;                        //审批流程节点列表
    Map<Long, Map<String, FormApprovePerson>> formApprovePersonMap;         //审批人列表 Map<审批节点编号,Map<人员Id,审批人mode>>
    Map<Long,Map<Long,Integer>> approveFieldPermissionMap;                  //审批节点对各个字段的权限   Map<节点编号,Map<字段编号,权限编号>> 默认只读权限，只读的不保存
    private List<FormFilled> formFilledList;                                //可见部门列表
    private List<FormUser> formUserList;                                    //可见人员列表
    private List<FormAdmin> formAdminList;                                  //管理员列表

    
    
    public Form getForm() {
        return form;
    }

    public void setForm(Form form) {
        this.form = form;
    }


    public List<FormField> getFormFieldList() {
        return formFieldList;
    }

    public void setFormFieldList(List<FormField> formFieldList) {
        this.formFieldList = formFieldList;
    }

    public Map<Long, List<FormFieldOption>> getFormFieldOptionMap() {
        return formFieldOptionMap;
    }

    public void setFormFieldOptionMap(Map<Long, List<FormFieldOption>> formFieldOptionMap) {
        this.formFieldOptionMap = formFieldOptionMap;
    }

    public void setFormFieldOptionList(List<FormFieldOption> formFieldList) {
        formFieldOptionMap = new HashMap<>();
        if (formFieldList != null) {
            for (FormFieldOption formFieldOption : formFieldList) {
                if (formFieldOptionMap.containsKey(formFieldOption.fieldId)) {
                    if (formFieldOptionMap.get(formFieldOption.fieldId) == null) formFieldOptionMap.put(formFieldOption.fieldId,new ArrayList<>());
                    formFieldOptionMap.get(formFieldOption.fieldId).add(formFieldOption);
                } else {
                    List<FormFieldOption> formFieldOptions = new ArrayList<>();
                    formFieldOptions.add(formFieldOption);
                    formFieldOptionMap.put(formFieldOption.fieldId,formFieldOptions);
                }
            }
        }
    }

    public Map<Long, List<FormField>> getFieldOptionReMap() {
        return fieldOptionReMap;
    }

    public void setFieldOptionReMap(Map<Long, List<FormField>> fieldOptionReMap) {
        this.fieldOptionReMap = fieldOptionReMap;
    }


    public List<FormOptionReField> getFormOptionReFieldList() {
        return formOptionReFieldList;
    }

    public void setFormOptionReFieldList(List<FormOptionReField> formOptionReFieldList) {
        this.formOptionReFieldList = formOptionReFieldList;
    }

    public List<FormApproveProcess> getFormApproveProcessList() {
        return formApproveProcessList;
    }

    public void setFormApproveProcessList(List<FormApproveProcess> formApproveProcessList) {
        this.formApproveProcessList = formApproveProcessList;
    }

    public Map<Long, Map<String, FormApprovePerson>> getFormApprovePersonMap() {
        return formApprovePersonMap;
    }

    public void setFormApprovePersonMap(Map<Long, Map<String, FormApprovePerson>> formApprovePersonMap) {
        this.formApprovePersonMap = formApprovePersonMap;
    }

    public Map<Long, Map<Long, Integer>> getApproveFieldPermissionMap() {
        return approveFieldPermissionMap;
    }

    public void setApproveFieldPermissionMap(Map<Long, Map<Long, Integer>> approveFieldPermissionMap) {
        this.approveFieldPermissionMap = approveFieldPermissionMap;
    }

    public List<FormFilled> getFormFilledList() {
        return formFilledList;
    }

    public void setFormFilledList(List<FormFilled> formFilledList) {
        this.formFilledList = formFilledList;
    }

    public List<FormUser> getFormUserList() {
        return formUserList;
    }

    public void setFormUserList(List<FormUser> formUserList) {
        this.formUserList = formUserList;
    }

    public List<FormAdmin> getFormAdminList() {
        return formAdminList;
    }

    public void setFormAdminList(List<FormAdmin> formAdminList) {
        this.formAdminList = formAdminList;
    }



    private Field[] setField(){
        Field[] fields = new Field[18];

        Field  f1 = new Field(1,"单行输入框","","请输入");
        Field  f2 = new Field(2,"多行输入框","","请输入");
        Field  f3 = new Field(3,"单选项","","请选择");
        Field  f4 = new Field(4,"多选项","","请选择");
        Field  f5 = new Field(5,"数字输入","","请输入");
        Field  f6 = new Field(6,"日期","","请选择");
        Field  f7 = new Field(7,"日期区间","","请选择");
        Field  f8 = new Field(8,"说明文字","","请输入");
        Field  f9 = new Field(9,"身份证","","请输入");
        Field  f10 = new Field(10,"图片","","请选择");
        Field  f11 = new Field(11,"金额","","请输入");
        Field  f12 = new Field(12,"附件","","请选择");
        Field  f13 = new Field(13,"经纬度","","请选择");
        Field  f14 = new Field(14,"计算公式","","请输入");
        Field  f15 = new Field(15,"联系人","","手写");
        Field  f16 = new Field(16,"手写","","请选择");
        Field  f17 = new Field(17,"关联其他表单","","请扫描");
        Field  f18 = new Field(18,"扫码","","请扫描");



        fields[0] = f1;
        fields[1] = f2;
        fields[2] = f3;
        fields[3] = f4;
        fields[4] = f5;
        fields[5] = f6;
        fields[6] = f7;
        fields[7] = f8;
        fields[8] = f9;
        fields[9] = f10;
        fields[10] = f11;
        fields[11] = f12;
        fields[12] = f13;
        fields[13] = f14;
        fields[14] = f15;
        fields[15] = f16;
        fields[16] = f17;
        fields[17] = f18;

        return fields;
    }
}
